// 可用的表单组件库
export const formElements = [
  {
    type: 'input',
    label: '单行文本',
    icon: 'Edit',
    options: {
      width: '100%',
      defaultValue: '',
      placeholder: '请输入',
      required: false,
      maxLength: null,
    },
  },
  {
    type: 'textarea',
    label: '多行文本',
    icon: 'Document',
    options: {
      width: '100%',
      defaultValue: '',
      placeholder: '请输入',
      required: false,
      rows: 4,
    },
  },
  {
    type: 'number',
    label: '数字输入',
    icon: 'Money',
    options: {
      width: '100%',
      defaultValue: 0,
      placeholder: '请输入数字',
      required: false,
      min: null,
      max: null,
    },
  },
  {
    type: 'select',
    label: '下拉选择',
    icon: 'ArrowDown',
    options: {
      width: '100%',
      defaultValue: '',
      required: false,
      options: [
        { label: '选项1', value: 'option1' },
        { label: '选项2', value: 'option2' },
      ],
    },
  },
  {
    type: 'radio',
    label: '单选框组',
    icon: 'CircleCheck',
    options: {
      defaultValue: '',
      required: false,
      options: [
        { label: '选项1', value: 'option1' },
        { label: '选项2', value: 'option2' },
      ],
    },
  },
  {
    type: 'checkbox',
    label: '多选框组',
    icon: 'Check',
    options: {
      defaultValue: [],
      required: false,
      options: [
        { label: '选项1', value: 'option1' },
        { label: '选项2', value: 'option2' },
      ],
    },
  },
  {
    type: 'date',
    label: '日期选择',
    icon: 'Calendar',
    options: {
      width: '100%',
      defaultValue: '',
      required: false,
      format: 'YYYY-MM-DD',
    },
  },
  {
    type: 'switch',
    label: '开关',
    icon: 'Switch',
    options: {
      defaultValue: false,
      required: false,
    },
  },
  // 新增：文档类组件
  {
    type: 'section',
    label: '章节标题',
    icon: 'Collection',
    options: {
      width: '100%',
      title: '章节标题',
      level: 2, // 1-6级标题
      required: false,
    },
  },
  {
    type: 'paragraph',
    label: '文本段落',
    icon: 'DocumentCopy',
    options: {
      width: '100%',
      content: '请输入段落内容...',
      required: false,
    },
  },
  {
    type: 'divider',
    label: '分割线',
    icon: 'Minus',
    options: {
      width: '100%',
      required: false,
    },
  },
  {
    type: 'signature',
    label: '签名区域',
    icon: 'EditPen',
    options: {
      width: '100%',
      label: '签名',
      required: false,
    },
  },
]

// 根据类型获取组件配置
export function getElementByType(type) {
  return formElements.find((item) => item.type === type)
}

// 模板定义
export const formTemplates = {
  // 法律文书模板
  legal: {
    name: '法律文书',
    items: [
      {
        type: 'section',
        label: '章节标题',
        options: {
          title: '起诉状',
          level: 1,
          required: false,
        },
        model: 'title',
      },
      {
        type: 'paragraph',
        label: '文本段落',
        options: {
          content: '原告：[请输入原告信息]',
          required: false,
        },
        model: 'plaintiff',
      },
      {
        type: 'paragraph',
        label: '文本段落',
        options: {
          content: '被告：[请输入被告信息]',
          required: false,
        },
        model: 'defendant',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '诉讼请求',
          placeholder: '请输入具体的诉讼请求...',
          rows: 6,
          required: true,
        },
        model: 'claims',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '事实与理由',
          placeholder: '详细陈述事实和理由...',
          rows: 8,
          required: true,
        },
        model: 'facts',
      },
      {
        type: 'divider',
        label: '分割线',
        options: {},
        model: 'divider1',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '起诉人',
          placeholder: '请输入起诉人姓名',
          required: true,
        },
        model: 'filer',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '起诉日期',
          required: true,
        },
        model: 'filingDate',
      },
      {
        type: 'signature',
        label: '签名区域',
        options: {
          label: '签名',
          required: true,
        },
        model: 'signature',
      },
    ],
  },
  // 公司章程模板
  corporate: {
    name: '公司章程',
    items: [
      {
        type: 'section',
        label: '章节标题',
        options: {
          title: '公司章程',
          level: 1,
          required: false,
        },
        model: 'title',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '公司名称',
          placeholder: '请输入公司全称',
          required: true,
        },
        model: 'companyName',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '注册资本',
          placeholder: '请输入注册资本金额',
          required: true,
        },
        model: 'registeredCapital',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '经营范围',
          placeholder: '详细描述公司经营范围...',
          rows: 4,
          required: true,
        },
        model: 'businessScope',
      },
      {
        type: 'section',
        label: '章节标题',
        options: {
          title: '第一章 总则',
          level: 2,
          required: false,
        },
        model: 'chapter1',
      },
      {
        type: 'paragraph',
        label: '文本段落',
        options: {
          content:
            '为规范公司的组织和行为，保护公司、股东和债权人的合法权益，根据《中华人民共和国公司法》等有关法律法规，制定本章程。',
          required: false,
        },
        model: 'generalProvisions',
      },
    ],
  },
  // 学生资料表模板
  student: {
    name: '学生资料表',
    items: [
      {
        type: 'section',
        label: '章节标题',
        options: {
          title: '学生基本信息登记表',
          level: 1,
          required: false,
        },
        model: 'title',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '学生姓名',
          placeholder: '请输入学生姓名',
          required: true,
        },
        model: 'studentName',
      },
      {
        type: 'radio',
        label: '单选框组',
        options: {
          label: '性别',
          required: true,
          options: [
            { label: '男', value: 'male' },
            { label: '女', value: 'female' },
          ],
        },
        model: 'gender',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '出生日期',
          required: true,
        },
        model: 'birthDate',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '班级',
          placeholder: '请输入班级',
          required: true,
        },
        model: 'className',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '学号',
          placeholder: '请输入学号',
          required: true,
        },
        model: 'studentId',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '家庭住址',
          placeholder: '请输入详细家庭住址',
          rows: 3,
          required: true,
        },
        model: 'address',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '监护人姓名',
          placeholder: '请输入监护人姓名',
          required: true,
        },
        model: 'guardianName',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '联系电话',
          placeholder: '请输入联系电话',
          required: true,
        },
        model: 'contactPhone',
      },
    ],
  },
  // 学生甲流感染登记表模板
  flu: {
    name: '学生甲流感染登记表',
    items: [
      {
        type: 'section',
        label: '章节标题',
        options: {
          title: '学生甲流感染登记表',
          level: 1,
          required: false,
        },
        model: 'title',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '学生姓名',
          placeholder: '请输入学生姓名',
          required: true,
        },
        model: 'studentName',
      },
      {
        type: 'radio',
        label: '单选框组',
        options: {
          label: '性别',
          required: true,
          options: [
            { label: '男', value: 'male' },
            { label: '女', value: 'female' },
          ],
        },
        model: 'gender',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '班级',
          placeholder: '请输入班级',
          required: true,
        },
        model: 'className',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '学号',
          placeholder: '请输入学号',
          required: true,
        },
        model: 'studentId',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '发病日期',
          required: true,
        },
        model: 'onsetDate',
      },
      {
        type: 'radio',
        label: '单选框组',
        options: {
          label: '是否有发热症状',
          required: true,
          options: [
            { label: '是', value: 'yes' },
            { label: '否', value: 'no' },
          ],
        },
        model: 'hasFever',
      },
      {
        type: 'number',
        label: '数字输入',
        options: {
          label: '最高体温(℃)',
          placeholder: '请输入体温',
          min: 35,
          max: 42,
        },
        model: 'temperature',
      },
      {
        type: 'checkbox',
        label: '多选框组',
        options: {
          label: '其他症状',
          required: false,
          options: [
            { label: '咳嗽', value: 'cough' },
            { label: '喉咙痛', value: 'soreThroat' },
            { label: '头痛', value: 'headache' },
            { label: '肌肉酸痛', value: 'musclePain' },
            { label: '乏力', value: 'fatigue' },
          ],
        },
        model: 'symptoms',
      },
      {
        type: 'radio',
        label: '单选框组',
        options: {
          label: '是否就医',
          required: true,
          options: [
            { label: '是', value: 'yes' },
            { label: '否', value: 'no' },
          ],
        },
        model: 'sawDoctor',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '就诊医院',
          placeholder: '请输入就诊医院名称',
        },
        model: 'hospital',
      },
      {
        type: 'radio',
        label: '单选框组',
        options: {
          label: '是否确诊甲流',
          required: true,
          options: [
            { label: '是', value: 'yes' },
            { label: '否', value: 'no' },
            { label: '待检测', value: 'pending' },
          ],
        },
        model: 'diagnosed',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '备注信息',
          placeholder: '请输入其他需要说明的情况...',
          rows: 3,
        },
        model: 'remarks',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '监护人姓名',
          placeholder: '请输入监护人姓名',
          required: true,
        },
        model: 'guardianName',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '联系电话',
          placeholder: '请输入联系电话',
          required: true,
        },
        model: 'contactPhone',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '登记日期',
          required: true,
        },
        model: 'registrationDate',
      },
      {
        type: 'signature',
        label: '签名区域',
        options: {
          label: '监护人签名',
          required: true,
        },
        model: 'guardianSignature',
      },
    ],
  },

  // 简历登记表模板
  resume: {
    name: '简历登记表',
    items: [
      {
        type: 'section',
        label: '章节标题',
        options: {
          title: '个人简历',
          level: 1,
          required: false,
        },
        model: 'title',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '姓名',
          placeholder: '请输入姓名',
          required: true,
        },
        model: 'name',
      },
      {
        type: 'radio',
        label: '单选框组',
        options: {
          label: '性别',
          required: true,
          options: [
            { label: '男', value: 'male' },
            { label: '女', value: 'female' },
          ],
        },
        model: 'gender',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '出生日期',
          required: true,
        },
        model: 'birthDate',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '联系电话',
          placeholder: '请输入联系电话',
          required: true,
        },
        model: 'phone',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '电子邮箱',
          placeholder: '请输入电子邮箱',
          required: true,
        },
        model: 'email',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '联系地址',
          placeholder: '请输入详细联系地址',
          rows: 2,
          required: true,
        },
        model: 'address',
      },
      {
        type: 'select',
        label: '下拉选择',
        options: {
          label: '最高学历',
          required: true,
          options: [
            { label: '高中', value: 'highSchool' },
            { label: '大专', value: 'college' },
            { label: '本科', value: 'bachelor' },
            { label: '硕士', value: 'master' },
            { label: '博士', value: 'doctor' },
          ],
        },
        model: 'education',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '毕业院校',
          placeholder: '请输入毕业院校',
          required: true,
        },
        model: 'school',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '专业',
          placeholder: '请输入所学专业',
          required: true,
        },
        model: 'major',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '毕业时间',
          required: true,
        },
        model: 'graduationDate',
      },
      {
        type: 'number',
        label: '数字输入',
        options: {
          label: '工作年限',
          placeholder: '请输入工作年限',
          min: 0,
          max: 50,
          required: true,
        },
        model: 'workYears',
      },
      {
        type: 'input',
        label: '单行文本',
        options: {
          label: '期望职位',
          placeholder: '请输入期望职位',
          required: true,
        },
        model: 'expectedPosition',
      },
      {
        type: 'select',
        label: '下拉选择',
        options: {
          label: '期望薪资',
          required: true,
          options: [
            { label: '面议', value: 'negotiable' },
            { label: '3000-5000元', value: '3k-5k' },
            { label: '5000-8000元', value: '5k-8k' },
            { label: '8000-12000元', value: '8k-12k' },
            { label: '12000-20000元', value: '12k-20k' },
            { label: '20000元以上', value: '20k+' },
          ],
        },
        model: 'expectedSalary',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '工作经历',
          placeholder: '请按时间顺序填写工作经历，包括公司名称、职位、工作内容等...',
          rows: 6,
          required: true,
        },
        model: 'workExperience',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '项目经验',
          placeholder: '请描述参与的主要项目经验...',
          rows: 4,
        },
        model: 'projectExperience',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '专业技能',
          placeholder: '请列出掌握的专业技能...',
          rows: 3,
        },
        model: 'skills',
      },
      {
        type: 'textarea',
        label: '多行文本',
        options: {
          label: '自我评价',
          placeholder: '请简要描述个人特点、职业规划等...',
          rows: 3,
        },
        model: 'selfEvaluation',
      },
      {
        type: 'date',
        label: '日期选择',
        options: {
          label: '填表日期',
          required: true,
        },
        model: 'fillingDate',
      },
    ],
  },
}
